#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2022/03/17
# @Author   :Changshu
# @File     :Exercise77.py
# 77. 组合
# 给定两个整数 n 和 k，返回范围 [1, n] 中所有可能的 k 个数的组合。
# 你可以按 任何顺序 返回答案。

import copy
def combine(n: int, k: int) -> list:
	sequences = []
	sequence = []

	def backtracking(n, k, startIndex):
		if len(sequence) == k:
			sequences.append(copy.deepcopy(sequence))
			return
		for i in range(startIndex, n + 1):
			sequence.append(i)
			backtracking(n, k, i + 1)
			sequence.pop()

	backtracking(n, k, 1)
	return sequences

def a(i):
	j=i+1
	def b(j):
		print(j)
	b(j)



if __name__ == '__main__':
	'''
	a=[b for b in range(10)]
	print(a)
	c=[[b] for b in range(10)]
	print(c)
	'''

	# a=[b for b in range(1,1)]
	# print(a)
	# c=[[b] for b in range(1,1)]
	# print(c)
	# for i in range(1,1):
	# 	print(i)
	# a=[1,2,3,4,5]
	# print(a.pop(0))
	# print(a)

	print(combine(4,2))
	# a(1)